package 蓝桥真题;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 错误票据 {
       static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
       final static int N=100010;
       static int a[]=new int[N],n,cnt;
       
       public static void main(String[] ss) throws  IOException {
		      n=Integer.parseInt(br.readLine());
		      while(n-->0){
		    	    ss=br.readLine().split(" ");
		    	    for(int i=0;i<ss.length;i++)
		    	    	a[cnt++]=Integer.parseInt(ss[i]);
		      }
		      Arrays.sort(a,0,cnt);
		      int m=0,n=0;
		      boolean dh=false,ch=false;;
		      for(int i=0;i<cnt-1;i++){
		    	  if(a[i]==a[i+1]){
		    		  n=a[i];
		    		  dh=true;
		    	  }else if(a[i]+1!=a[i+1]){
		    		  m=a[i]+1;
		    		  ch=true;
		    	  }
		    	  if(dh&&ch)break;
		      }
		      System.out.print(m+" "+n);
	}
}
